
$('.btn-submit').on('click',function(){
    var name = $('#inputName').val().trim();
    var password = $('#inputPassword').val().trim();
    var confirmation = $('#inputConfirmation').val().trim();


    if(!name){
        showMsg($('.error-info'),'Please input name');
        return
    }

    if(!password){
       showMsg($('.error-info'),'Please input password');
       return
    }

    if(!confirmation){
        showMsg($('.error-info'),'Please input confirmation');
        return
    }

    if(password!=confirmation){
        showMsg($('.error-info'),'The two password inputs are different');
        return
    }
    
    $.ajax({
        url:studentUrl,
        type:'POST',
        headers: {
        'X-CSRF-TOKEN':$('meta[name="csrf-token"]').attr('content')
        },
        data:{
            name:name,
            password:password,
            confirmation:confirmation
        }
    }).done(function(res){
        if(res.success){
            window.location.href=loginUrl;
        }else{
           showMsg($('.error-info'),'Sign in fail');
        }
    }).fail(function(xhr){
        showMsg($('.error-info'),'Server error');
        console.log(xhr)
    });

});